<template>
    <div class="earlyWarning">
        <el-carousel indicator-position="outside" height="200px" interval="4000">
            <el-carousel-item v-for="(item, index) in tableData" :key="index">
                <!-- <h3>{{ item }}</h3> -->
                <div class="count-title">
                    {{ item.branch_id_name }}任务</div>
                <div class="count-wrap">
                    <div class="tableELCol" @click="Timeoutjump(item.branch_id, item.collect_id)"
                        v-if="item.collect_count != ''">
                        <div class="tableELColMe">
                            {{ item.collect_count }}</div>
                        <div class="item-text">{{ item.collect_id_name }}超时</div>
                    </div>
                    <div class="tableELCol" v-if="item.dispatch_count != ''"
                        @click="Timeoutjump(item.branch_id, item.dispatch_id)">
                        <div class="tableELColMe">
                            {{ item.dispatch_count }}</div>
                        <div class="item-text">{{ item.dispatch_id_name }}超时</div>
                    </div>
                    <div class="tableELCol" v-if="item.distribution_count != ''"
                        @click="Timeoutjump(item.branch_id, item.distribution_id)">
                        <div class="tableELColMe">
                            {{ item.distribution_count }}</div>
                        <div class="item-text">{{ item.distribution_id_name }}超时</div>
                    </div>
                    <div class="tableELCol" v-if="item.sign_count != ''" @click="Timeoutjump(item.branch_id, item.sign_id)">
                        <div class="tableELColMe">
                            {{ item.sign_count }}</div>
                        <div class="item-text">{{ item.sign_id_name }}超时</div>
                    </div>
                    <!--  回单创建-->
                    <div class="tableELCol" v-if="item.receipt_create_count != ''"
                        @click="Timeoutjump(item.branch_id, item.receipt_create_id)">
                        <div class="tableELColMe">
                            {{ item.receipt_create_count }}</div>
                        <div class="item-text">{{ item.receipt_create_id_name }}</div>
                    </div>
                    <!-- 回单签收 -->
                    <div class="tableELCol" v-if="item.receipt_sign_count != ''"
                        @click="Timeoutjump(item.branch_id, item.receipt_sign_id)">
                        <div class="tableELColMe">
                            {{ item.receipt_sign_count }}</div>
                        <div class="item-text">{{ item.receipt_sign_id_name }}</div>
                    </div>
                    <!-- 回箱创建时间 -->
                    <div class="tableELCol" v-if="item.box_recycle_create_count != ''"
                        @click="Timeoutjump(item.branch_id, item.box_recycle_create_id)">
                        <div class="tableELColMe">
                            {{ item.box_recycle_create_count }}</div>
                        <div class="item-text">{{ item.box_recycle_create_id_name }}</div>
                    </div>
                    <!-- 回箱签收 -->
                    <div class="tableELCol" v-if="item.box_recycle_sign_count != ''"
                        @click="Timeoutjump(item.branch_id, item.box_recycle_sign_id)">
                        <div class="tableELColMe">
                            {{ item.box_recycle_sign_count }}</div>
                        <div class="item-text">{{ item.box_recycle_sign_id_name }}</div>
                    </div>
                </div>
            </el-carousel-item>
        </el-carousel>
        <!-- <div v-if="tableData.length == 0" class="tablestyle_One"
            style="background: linear-gradient( #E3F0FF, #FFFFFF);text-align: center;font-weight: 580;font-size: 14px;line-height:40px;">
            暂无任务</div>
        <div class="box-wrapper">
            <div v-if="tableData.length == 1">
                <div class="tablestyle_One" v-for="(item, index) in tableData"
                    :style="{ 'background': getBackgroundColor(index) }">
                    <div style="text-align: center;font-size: 16px ;font-weight: bold;padding: 10px 0px 0px 0px;">
                        {{ item.branch_id_name }}任务</div>
                    <div style="display: flex;flex-wrap:wrap;justify-content: space-between">
                        <div class="tableELCol" @click="Timeoutjump(item.branch_id, item.collect_id)"
                            v-if="item.collect_count != ''">
                            <div class="tableELColMe">
                                {{ item.collect_count }}</div>
                            <div style="line-height: 24px;color: #4c9bfd;">{{ item.collect_id_name }}超时</div>
                        </div>
                        <div class="tableELCol" v-if="item.dispatch_count != ''"
                            @click="Timeoutjump(item.branch_id, item.dispatch_id)">
                            <div class="tableELColMe">
                                {{ item.dispatch_count }}</div>
                            <div style="line-height: 24px;color: #4c9bfd;">{{ item.dispatch_id_name }}超时</div>
                        </div>
                        <div class="tableELCol" v-if="item.distribution_count != ''"
                            @click="Timeoutjump(item.branch_id, item.distribution_id)">
                            <div class="tableELColMe">
                                {{ item.distribution_count }}</div>
                            <div style="line-height: 24px;color: #4c9bfd;">{{ item.distribution_id_name }}超时</div>
                        </div>
                        <div class="tableELCol" v-if="item.sign_count != ''"
                            @click="Timeoutjump(item.branch_id, item.sign_id)">
                            <div class="tableELColMe">
                                {{ item.sign_count }}</div>
                            <div style="line-height: 24px;color: #4c9bfd;">{{ item.sign_id_name }}超时</div>
                        </div>
                        <div class="tableELCol" v-if="item.receipt_count != ''"
                            @click="Timeoutjump(item.branch_id, item.receipt_id)">
                            <div class="tableELColMe">
                                {{ item.receipt_count }}</div>
                            <div style="line-height: 24px;color: #4c9bfd;">{{ item.receipt_id_name }}超时</div>
                        </div>
                        <div class="tableELCol" v-if="item.box_recycle_count != ''"
                            @click="Timeoutjump(item.branch_id, item.box_recycle_id)">
                            <div class="tableELColMe">
                                {{ item.box_recycle_count }}</div>
                            <div style="line-height: 24px;color: #4c9bfd;">{{ item.box_recycle_id_name }}超时</div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="grid" v-else>
                <div class="grid-item" v-for="(item, index) in tableData" :style="{ 'background': getBackgroundColor(index) }">
                    <div style="text-align: center;font-size: 16px ;font-weight: bold;padding: 10px 0px 0px 0px;">
                        {{ item.branch_id_name }}任务</div>
                    <div style="display: flex;flex-wrap:wrap;">
                        <div class="tableELCol" @click="Timeoutjump(item.branch_id, item.collect_id)"
                            v-if="item.collect_count != ''">
                            <div class="tableELColMe">
                                {{ item.collect_count }}</div>
                            <div style="line-height: 24px;color: #4c9bfd;">{{ item.collect_id_name }}超时</div>
                        </div>
                        <div class="tableELCol" v-if="item.dispatch_count != ''"
                            @click="Timeoutjump(item.branch_id, item.dispatch_id)">
                            <div class="tableELColMe">
                                {{ item.dispatch_count }}</div>
                            <div style="line-height: 24px;color: #4c9bfd;">{{ item.dispatch_id_name }}超时</div>
                        </div>
                        <div class="tableELCol" v-if="item.distribution_count != ''"
                            @click="Timeoutjump(item.branch_id, item.distribution_id)">
                            <div class="tableELColMe">
                                {{ item.distribution_count }}</div>
                            <div style="line-height: 24px;color: #4c9bfd;">{{ item.distribution_id_name }}超时</div>
                        </div>
                        <div class="tableELCol" v-if="item.sign_count != ''"
                            @click="Timeoutjump(item.branch_id, item.sign_id)">
                            <div class="tableELColMe">
                                {{ item.sign_count }}</div>
                            <div style="line-height: 24px;color: #4c9bfd;">{{ item.sign_id_name }}超时</div>
                        </div>
                        <div class="tableELCol" v-if="item.receipt_count != ''"
                            @click="Timeoutjump(item.branch_id, item.receipt_id)">
                            <div class="tableELColMe">
                                {{ item.receipt_count }}</div>
                            <div style="line-height: 24px;color: #4c9bfd;">{{ item.receipt_id_name }}超时</div>
                        </div>
                        <div class="tableELCol" v-if="item.box_recycle_count != ''"
                            @click="Timeoutjump(item.branch_id, item.box_recycle_id)">
                            <div class="tableELColMe">
                                {{ item.box_recycle_count }}</div>
                            <div style="line-height: 24px;color: #4c9bfd;">{{ item.box_recycle_id_name }}超时</div>
                        </div>
                    </div>
                </div>
            </div>
        </div> -->
    </div>
</template>

<script>
// import {
//     overtimerecordsshow
// } from "@/api/Largewidthmeterlist";
import { getChartData } from "@/api/echarts";
import { getNowFormatDate } from "@/utils/auth";
export default {
    name: 'rangeStatistics',
    components: {},
    props: [],
    data() {
        return {
            tableData: [],
        };
    },
    mounted() {
        this.thermometermonitorObj();
    },
    methods: {
        getBackgroundColor(value) {
            // 根据不同的值返回不同的颜色
            if (value == 0) {
                return 'linear-gradient( #E3F0FF, #FFFFFF)';
            } else if (value == 1) {
                return 'linear-gradient( #FFFBEA, #FFFFFF)';
            } else if (value == 2) {
                return 'linear-gradient( #F0F9EB, #FFFFFF)';
            } else if (value == 3) {
                return 'linear-gradient(#F4F4F5, #FFFFFF)';
            } else if (value == 4) {
                return 'linear-gradient(#FEF0F0, #FFFFFF)';
            }
            else {
                return 'linear-gradient( #E3F0FF, #FFFFFF)';
            }
        },
        thermometermonitorObj() {
            var newnow = getNowFormatDate();
            var param = {
                custom_chart_id: "23",
                "create_day": newnow,

            };
            getChartData(param).then((res) => {
                this.tableData = res.data.data;
            });
        },
        Timeoutjump(router, node_id) {
            this.$router.push({
                name: "TimeOutwarningList", query: {
                    branch_id: router,
                    node_id: node_id,
                }
            });
        },
    },
};
</script>
<style lang="scss" scoped>
.earlyWarning::-webkit-scrollbar {
    width: 3px;
}

.earlyWarning::-webkit-scrollbar-track {
    background: rgb(239, 239, 239);
    border-radius: 2px;
}

.earlyWarning::-webkit-scrollbar-thumb {
    background: #B6B6B6;
    border-radius: 10px;
}

.earlyWarning::-webkit-scrollbar-thumb:hover {
    background: #B6B6B6;
}

.earlyWarning {
    // overflow-x: hidden;
    // overflow-y: scroll;
    height: 260px;
    padding: 0px 3px 0px 0px;
    font-size: 15px;

    .count-title {
        text-align: center;
        font-size: 16px;
        font-weight: bold;
        padding: 15px 0px 25px 0px;
        margin-bottom: 10px;
        color: #4c9bfd;
    }

    .tablestyle {
        margin: 0 auto;
        width: 50%;
        border-radius: 6px;
        margin-bottom: 10px;
        border: 1px solid #B2B9D4;
        margin-top: 10px;
        margin-right: 10px;
        margin-left: 10px;
    }

    .tablestyle_One {
        margin: 0 auto;
        border-radius: 6px;
        margin-bottom: 10px;
        border: 1px solid #B2B9D4;
        margin-top: 10px;
        padding: 0px 10px 0px 0px;
    }

    .tableELCol {
        height: 50px;
        text-align: center;
        Cursor: pointer;
        width: 25%;
    }

    .tableELColMe {
        font-weight: bold;
        color: #fff;
    }

    .grid {
        column-count: 2;
        /* 设置列数 */
        column-gap: 8px;
        /* 设置列之间的间隔 */
    }

    .grid-item {
        display: inline-block;
        width: 100%;
        /* 每个项目的宽度 */
        margin-top: 8px;
        border-radius: 6px;
        border: 1px solid #B2B9D4;
        /* 设置项目之间的垂直间距 */
    }
}

.count-wrap {
    display: flex;
    flex-wrap: wrap;
    .item-text {
        line-height: 24px;
        color: #4c9bfd;
    }
}
</style>